package Week4.J0511;

import java.util.Scanner;

public class 小葱的01串_xv {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        char[] s = scanner.next().toCharArray();

        int[] sum = new int[2]; // 统计字符串中 0 和 1 的个数
        for (int i = 0; i < n; i++) {
            sum[s[i] - '0']++;
        }

        int left = 0, right = 0, ret = 0; int half = n / 2;
        
        int[] count = new int[2]; // 统计窗口内 0 和 1 的个数
        while (right < n - 1) {
            count[s[right] - '0']++;

            while (right - left + 1 > half) {
                count[s[left++] - '0']--;
            }

            if (right - left + 1 == half) {
                if (count[0] * 2 == sum[0] && count[1] * 2 == sum[1]) {
                    ret += 2;
                }
            }
            right++;
        }

        System.out.println(ret);
    }
}
